﻿
    
    <Window x:Class="Samurai.Client.Windows.EditMovieWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:Samurai.Client.Controls"
        Title="EditMovieWindow" Height="350" Width="600">

    <Border Margin="5" BorderBrush="Black" BorderThickness="2" CornerRadius="5">
        <Grid x:Name="MainRegion"
          ShowGridLines="True"
          Background="{DynamicResource OrangeGradientBrush}"
          Opacity="{Binding IsWaiting, Converter={StaticResource IsWaitingToOpacityConverter}}">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="127*" />
                <ColumnDefinition Width="201*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="58*" />
                <RowDefinition Height="190*" />
                <RowDefinition Height="63*" />
            </Grid.RowDefinitions>

            <Controls:Spinner
        Visibility="{Binding IsWaiting, Converter={StaticResource BooleanToVisibilityConverter}}"
        Panel.ZIndex="1000"
        Grid.Row="0"
        Grid.Column="0"
        Grid.RowSpan="3"
        Grid.ColumnSpan="2">
                <Controls:Spinner.RenderTransform>
                    <ScaleTransform
            CenterX="{Binding ElementName=MainRegion, Path=ActualWidth, Converter={StaticResource Div2Converter}}"
            CenterY="{Binding ElementName=MainRegion, Path=ActualHeight, Converter={StaticResource Div2Converter}}"
            ScaleX="0.5"
            ScaleY="0.5" />
                </Controls:Spinner.RenderTransform>

            </Controls:Spinner>

            <Grid x:Name="HeaderRegion" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
                <TextBlock FontSize="18" Text="Edit Movie" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" />
            </Grid>

            <Grid x:Name="LeftBodyRegion" Grid.Row="1" Grid.Column="0">
                <Image Grid.Row="0" Grid.Column="0" Grid.RowSpan="3" HorizontalAlignment="Center" VerticalAlignment="Center" Source="{Binding Image, Converter={StaticResource ByteArrayToImageConverter}}" />
            </Grid>

            <Grid ShowGridLines="True" x:Name="RightBodyRegion" Grid.Row="1" Grid.Column="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="75" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <TextBlock x:Name="labelLocation"
                           TextAlignment="Center"
                    Grid.Row="1" 
                    Grid.Column="1" 
                    Margin="2" 
                    Height="25" 
                    Text="{Binding Path}" 
                    ToolTip="{Binding Path}" Padding="4" />

                <TextBlock x:Name="textBlockLocation"
                           TextAlignment="Center"
                 Grid.Row="1"
                 Grid.Column="0"
                 Grid.ColumnSpan="1"
                 Text="Location"
                 Margin="0"
                 Height="25"                                         
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center" Padding="4" />

                <TextBox x:Name="textBoxTitle" 
                 Grid.Row="0"
                 Grid.Column="1" 
                 Grid.ColumnSpan="1" 
                 Text="{Binding Title, Mode=TwoWay}" 
                 Margin="2"                  
                 Height="25"
                 HorizontalAlignment="Stretch" 
                 VerticalAlignment="Center" />

                <TextBlock x:Name="labelTitle"
                 TextAlignment="Center"
                 Grid.Row="0"
                 Grid.Column="0"
                 Grid.ColumnSpan="1"
                 Text="Title"
                 Margin="0"
                 Height="25"                                         
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center" Padding="4" />

            </Grid>

            <StackPanel Orientation="Horizontal" x:Name="ToolsRegion" FlowDirection="RightToLeft" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">

                <Button Style="{DynamicResource RectangleGlassButton}" Width="39" Height="22" Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" 
                Content="Preview" 
                Command="{Binding PreviewMovieCommand}" 
                CommandParameter="{Binding ElementName=textBoxTitle, Path=Text}" />

                <Button Style="{DynamicResource RectangleGlassButton}" Width="39" Height="22" Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" 
                Content="OK" 
                Command="{Binding CommitMovieEditCommand}" 
                CommandParameter="{Binding Movie}" />

                <Button Style="{DynamicResource RectangleGlassButton}" Width="39" Height="22" Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" 
                Content="Cancel" 
                Command="{Binding CancelMovieEditCommand}" />

            </StackPanel>

        </Grid>
    </Border>
</Window>
